package com.yy.personalcv.service.impl;

import com.yy.personalcv.mapper.UserInformationMapper;
import com.yy.personalcv.pojo.UserInformation;
import com.yy.personalcv.service.UserInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class UserInformationServiceImpl implements UserInformationService {

    @Resource
    private UserInformationMapper userInformationMapper;

    @Override
    public int selectIdByName(String username) {
        try {
            return this.userInformationMapper.selectIdByName(username);
        } catch (Exception e) {
            return 0;
        }
    }

    @Override
    public UserInformation selectByPrimaryKey(int uid) {
        return this.userInformationMapper.selectByPrimaryKey(uid);
    }

    @Override
    public void updateUserInformation(UserInformation userInformation) {
        userInformation.setModified(new Date());
        this.userInformationMapper.updateByPrimaryKeySelective(userInformation);
    }
}
